﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
<link href="@Url.Content("~/Scripts/upload/jquery.fileupload-ui.css")" type="text/css" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/upload/jquery.fileupload.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/upload/jquery.fileupload-ui.js")" type="text/javascript"></script>


<script type="text/javascript">
    $(function () {
        setTimeout(function () {
            $('#file_upload').fileUploadUI({
                url: '/TesteUpload/Salvar',
                method: 'POST',
                uploadTable: $('#files'),
                downloadTable: $('#files'),
                buildUploadRow: function (files, index) {
                    for (var propertyName in files) {
                        alert(propertyName);
                    }
                    return $('<tr><td>' + files[index].name + '<\/td>' +
					'<td class="file_upload_progress"><div><\/div><\/td>' +
					'<td class="file_upload_cancel">&nbsp;<\/td><\/tr>');
                },
                buildDownloadRow: function (file) {
                    if (file == "")
                        return;

                    $("#ex").prepend('<img src="' + file.Path + '"/>');
                }
            });
        }, 0);
    });
</script>


}


<div id="ex">
    <form id="file_upload" >
	    <div class="span-24">
		    <table id="files"></table>
	    </div>
	    <br />
	    <div class="span-24" style="text-align:center;">
		    <div id="filediv" class="ui-button ui-widget ui-state-default ui-corner-all">
			    <input type="file" name="file" multiple>
			    <button>Upload</button>
			    <div>Incluir arquivos</div>
		    </div>
	    </div>
    </form>
</div>
